﻿using System.Collections.Generic;
using System.Windows.Controls;
using Alimentador.Foods;

namespace Alimentador.RightGroup
{
    /// <summary>
    /// Interaction logic for RightGroupCtrl.xaml
    /// </summary>
    public partial class RightGroupCtrl : UserControl
    {
        public delegate void LoadDataEventDelegate(bool loaded);
        public event LoadDataEventDelegate LoadDataEvent;

        public RightGroupCtrl()
        {
            InitializeComponent();

            AddEvents();
        }

        /// <summary>
        /// Set components event handlers
        /// </summary>
        private void AddEvents()
        {
            PatientTabCtrl.LoadDataEvent += PatientTabCtrl_LoadDataEvent;
        }

        /// <summary>
        /// Lauch a Loaded event with the given value
        /// </summary>
        /// <param name="loaded"></param>
        private void PatientTabCtrl_LoadDataEvent(bool loaded)
        {
            if (LoadDataEvent != null)
            {
                LoadDataEvent(loaded);
            }
        }

        private List<FoodBase> m_foodList = null;

        internal void AddFood(List<FoodBase> foodList, int numDays = 1)
        {
            m_foodList = foodList;
            ResultsTabCtrl.LoadObtainedValues(foodList, numDays);
        }
    }
}
